package com.winit.openapi.sms.validator;

import com.alibaba.fastjson.JSONObject;
import com.winit.openapi.constants.ErrorCode;
import com.winit.openapi.exception.ApiException;
import com.winit.openapi.util.ValidateUtil;

/**
 * 分销平台线下充值单
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * keke.xu 	1.0  		2016年4月11日 	Created
 *
 * </pre>
 * @since 1.
 */
public class AdvanceRechargeFieldValidator {

    /**
     * 导入分销平台线下充值单参数校验
     * 
     * @param json
     */
    public static void validImportAdvanceRechargeField(JSONObject json) {
        ValidateUtil.validImportMaxLength(json, "bankAccountNo", "收款账号", 64, true);
        //        ValidateUtil.validMaxLengthTwo(json, "sourceAmount", null, 20, true);
        ValidateUtil.validImportMaxLength(json, "currencyCode", "币种", 3, true);
        ValidateUtil.isNotNull(json, "attachment");
        ValidateUtil.validImportMaxLength(json, "advanceName", "付款人名称", 64, true);
        // 校验是否存在特殊字符
        if (!json.getString("advanceName").matches("[^@#￥$%&(){}<>]{0,}")) {
            throw new ApiException(ErrorCode.NOT_INPUT_SPECHARS, "付款人名称");
        }
        ValidateUtil.validImportMaxLength(json, "advanceType", "付款账户类型", 32, true);
        ValidateUtil.isNotNull(json, "batchNumber");
        ValidateUtil.isNotNull(json, "lineTotal");
    }

    /**
     * 批次
     * 
     * @param json
     */
    public static void validQueryExchangeRateField(JSONObject json) {
        ValidateUtil.isNotNull(json, "batchNumber");
    }

    /**
     * 客户编码
     * 
     * @param json
     */
    public static void validQueryAvailableBalanceField(JSONObject json) {
        ValidateUtil.isNotNull(json, "customerName");
    }
}
